package cn.tedu.csmallpassport.controller;

import cn.tedu.csmallpassport.ex.ServiceException;
import cn.tedu.csmallpassport.pojo.dto.AdminAddNewDTO;
import cn.tedu.csmallpassport.service.AdminService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/admin")
@RestController
@Api(tags = "1.相册管理模块")
@Slf4j
public class AdminController {
    @Autowired
    private AdminService service;

    /**
     *
     */
    @ApiOperation("添加相册")
    @RequestMapping(path = "/add-new",method = RequestMethod.POST)
    public String AddAdmin(AdminAddNewDTO adminAddNewDTO){
        try {
            service.AddNew(adminAddNewDTO);
            log.info("添加管理员成功");
            return "添加成功";
        } catch (ServiceException e) {
            log.info("{}",e.getMessage());
            return e.getMessage();
        }

    }

}
